﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using ChineseSchool.Models.Hethong;

namespace ChineseSchool.BLL
{
    public class B_MenuType
    {
        private PetaPoco.Database db;
        public B_MenuType()
        {
            db = new PetaPoco.Database("ConnectionString");
        }

        public DataTable GetAll()
        {
            DataTable dt = new DataTable();
            dt = db.ExecuteReader("EXEC MenuType_Get_List");
            return dt;
        }
        
        public List<M_MenuType> GetAlls()
        {
            var MenuType = db.Fetch<M_MenuType>(@";EXEC MenuType_Get_List");
            return MenuType;
        }

        public M_MenuType GetByPK(int MenuTypeID)
        {
            var loadMenuType = db.SingleOrDefault<M_MenuType>("SELECT * FROM MenuType m WHERE m.MenuTypeID = " + MenuTypeID + ";");
            db.CloseSharedConnection();
            return loadMenuType;
        }        
    }
}